import pymysql
conn = pymysql.connect(host="localhost", user="root", password="Password@1234", db="test_db", 
        port=3306, charset="utf8")
cursor = conn.cursor()
create_sql = 'CREATE TABLE stocks(code text, name text, price real)'
cursor.execute(create_sql)
stock_tuple = (('601288', '农业银行', 3.16),
               ('601398', '工商银行', 4.94),
               ('601939', '建设银行', 6.19))
insert_sql = "insert into stocks values(%s,%s,%s)"
cursor.executemany(insert_sql, stock_tuple)
conn.commit()
cursor.execute('select * from stocks')
print(cursor.fetchone())
cursor.close()
conn.close()